<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../引入vue2.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
            list-style: none;
            display: flex;
        }

        li {
            flex: 1;
            height: 50px;
            line-height: 50px;
            text-align: center;
        }

        .active {
            background: yellowgreen;
        }
    </style>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="(data,index) in list" @click='onClick(index)' :class="cengji===index?'active':''">
                {{data}}
            </li>
        </ul>
    </div>
</body>
<script>
    let vm = new Vue({
        el: '#app',
        data: {
            list: ['首页', '列表', '我的'],
            cengji: 0
        },
        methods: {
            onClick(index) {
                console.log(index);
                this.cengji = index;
            }
        },
    })
</script>

</html>